/**
 * @type {Number}
 *
 * @properties={typeid:35,uuid:"7A7A28A9-D4D1-44FF-B7B1-F0DCFC025E82",variableType:8}
 */
var fIva_1 = null;

/**
 * @type {Number}
 *
 * @properties={typeid:35,uuid:"723958BC-4931-4080-8E89-3F984A8C71C7",variableType:8}
 */
var fIva_2 = null;

/**
 * @type {Number}
 *
 * @properties={typeid:35,uuid:"854FEA1D-39A4-4D3D-9E9C-14439528A5F8",variableType:8}
 */
var fIva_3 = null;

/**
 * @type {Number}
 *
 * @properties={typeid:35,uuid:"9D812A9B-7181-418B-91DB-846C5B73DEEE",variableType:8}
 */
var fIva_4 = null;

/**
 * @type {Number}
 *
 * @properties={typeid:35,uuid:"853FA3D0-5947-4DF9-84C7-C50943CDB41B",variableType:8}
 */
var fNeto_1 = null;

/**
 * @type {Number}
 *
 * @properties={typeid:35,uuid:"AFCAFAF2-77D7-4C66-A9AA-34E62EE3F760",variableType:8}
 */
var fNeto_2 = null;

/**
 * @type {Number}
 *
 * @properties={typeid:35,uuid:"4C3111D5-F7F1-4409-A78F-C32F28E07630",variableType:8}
 */
var fNeto_3 = null;

/**
 * @type {Number}
 *
 * @properties={typeid:35,uuid:"DC18ECB7-B5DC-489E-96C4-B33AA913EB63",variableType:8}
 */
var fNeto_4 = null;

/**
 * @type {Number}
 *
 * @properties={typeid:35,uuid:"310744CF-708E-4AEF-ABA7-52C068C64B9C",variableType:8}
 */
var porc_1 = null;

/**
 * @type {Number}
 *
 * @properties={typeid:35,uuid:"B64AC63C-D0CA-4B5B-8502-868D95B806B1",variableType:8}
 */
var porc_2 = null;

/**
 * @type {Number}
 *
 * @properties={typeid:35,uuid:"66B71ECF-3B33-466C-B940-3ED21593FB44",variableType:8}
 */
var porc_3 = null;

/**
 * @type {Number}
 *
 * @properties={typeid:35,uuid:"89FBA43C-8E8E-48BD-8D6C-5D1DB8A45E55",variableType:8}
 */
var porc_4 = null;

/**
 * @type {Number}
 *
 * @properties={typeid:35,uuid:"43D497EE-CEAB-49FC-9602-7C72DF157299",variableType:8}
 */
var T_importe = null;

/**
 * @type {Number}
 *
 * @properties={typeid:35,uuid:"0692E449-5166-42DF-8001-A24A79476E25",variableType:8}
 */
var T_iva = null;

/**
 * @type {Number}
 *
 * @properties={typeid:35,uuid:"B417C400-1F2D-44BE-B4EC-82D467E31C95",variableType:8}
 */
var T_neto = null;

/**
 *
 * @properties={typeid:24,uuid:"022F41D4-70B0-4AD5-95FA-7634D3D32FB5"}
 */
function calcular_totales()
{
	//application.output('calcular totales')
	
	// arma dataset
	//**//var tabla_totales = databaseManager.createEmptyDataSet(50,3)   habilitar cuando funcione
	var tabla_totales = databaseManager.createEmptyDataSet(10,3)
	
	//**//for ( var k = 0 ; k < 50 ; k ++ )
	for ( var k = 0 ; k < 10 ; k ++ )
	{
		tabla_totales.setValue(k, 1, 0.00);
		tabla_totales.setValue(k, 2, 0.00);
		tabla_totales.setValue(k, 3, 0.00);	
	}
	
	// recorre foundset
	T_neto=0
	T_iva=0
	T_importe=0
	for ( var i = 1 ; i <= controller.getMaxRecordIndex(); i++ )
	{
		foundset.setSelectedIndex(i)
		
		//  usando calculations
		T_neto 		+= neto_signo
		T_iva		+= iva_signo
		T_importe	+= importe_signo
		
		var k = ctacte_cl_to_tasa_iva_porc.tasa_iva_id
			
		tabla_totales.setValue(k, 1, iva_porc)
		tabla_totales.setValue(k, 2, tabla_totales.getValue(k, 2) + iva_signo)
		tabla_totales.setValue(k, 3, tabla_totales.getValue(k, 3) + neto_signo)
	}
	
	for ( var k = 1 ; k <= 10 ; k ++ )
	{
		if (tabla_totales.getValue(k, 1) != 0 && tabla_totales.getValue(k, 2) != 0 && tabla_totales.getValue(k, 3) != 0)		
		{   /*
			application.output(k)
			application.output('porcentaje')
			application.output(tabla_totales.getValue(k, 1))
			application.output('iva')
			application.output(tabla_totales.getValue(k, 2))
			application.output('neto')
			application.output(tabla_totales.getValue(k, 3))    */
		}
		else
		{
			//	application.output('son todos ceros')
			fIva_1=tabla_totales.getValue(1, 2)
			fIva_2=tabla_totales.getValue(2, 2)
			fIva_3=tabla_totales.getValue(3, 2)
			fIva_4=tabla_totales.getValue(4, 2)
			porc_1=tabla_totales.getValue(1, 1)
			porc_2=tabla_totales.getValue(2, 1)
			porc_3=tabla_totales.getValue(3, 1)
			porc_4=tabla_totales.getValue(4, 1)
			fNeto_1=tabla_totales.getValue(1, 3)
			fNeto_2=tabla_totales.getValue(2, 3)
			fNeto_3=tabla_totales.getValue(3, 3)
			fNeto_4=tabla_totales.getValue(4, 3)
		}
	}               
}

/**
 * @properties={typeid:24,uuid:"C9A1E16B-5637-4A77-94D2-875E8FED19E5"}
 */
function imprimir() 
{
	forms.diario_reten_2_imp.controller.showPrintPreview(false)
}

/**
 * @properties={typeid:24,uuid:"24BD6253-2842-4C60-9A9D-CB5A212C2611"}
 */
function pdf() 
{
	globals.metodoPdf('diario_reten_2_imp','Diario_retenciones',true)
}
